/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.OrderDetailView;
import com.ruipengkj.commons.base.query.BaseQuery;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.StatmentOrderDetailViewDao;
import com.ruipengkj.service.StatmentOrderDetailViewService;
/**
 * 说明：
 * 商品采购汇总表Service层接口实现
 * @Author：李智深
 * @Date：2012-03-16
 */
@Service
public class StatementOrderDetailViewServiceImpl implements StatmentOrderDetailViewService{

	@Resource
	private StatmentOrderDetailViewDao StatmentOrderDetailViewDao;//DAO层

	public StatmentOrderDetailViewDao getStatmentOrderDetailViewDao() {
		return StatmentOrderDetailViewDao;
	}

	public void setStatmentOrderDetailViewDao(
			StatmentOrderDetailViewDao statmentOrderDetailViewDao) {
		StatmentOrderDetailViewDao = statmentOrderDetailViewDao;
	}

	@Override
	public void deleteService(String id) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<OrderDetailView> findService(OrderDetailView entity)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public OrderDetailView getByIdService(String id) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public PageModel<OrderDetailView> getScrollService(int firstResult,
			int maxResult, OrderDetailView entity) throws Exception {
		String hql = "select o from OrderDetailView o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(entity.getHappenTime()!=null && !entity.getHappenTime().equals("")){
				whereHQL.append("o.happenTime>=? ").append(BaseQuery.AND);
				param.add(entity.getHappenTime());
			}
			if(entity.getEndTime()!=null && !entity.getEndTime().equals("")){
				whereHQL.append("o.happenTime <=? ").append(BaseQuery.AND);
				param.add(entity.getEndTime());
			}
	
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		
//		PageModel<OrderDetailView> pageMode=StatmentOrderDetailViewDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
		//System.out.println(pageMode.getResultList());
		return StatmentOrderDetailViewDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}

	@Override
	public void modifyService(OrderDetailView entity) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void saveOrUpdateService(OrderDetailView entity) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Serializable saveRetService(OrderDetailView entity) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void saveService(OrderDetailView entity) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<OrderDetailView> findExportService(
			OrderDetailView entity) throws Exception {
		String hql = "select o from OrderDetailView o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(entity.getHappenTime()!=null && !entity.getHappenTime().equals("")){
				whereHQL.append("o.happenTime>=? ").append(BaseQuery.AND);
				param.add(entity.getHappenTime());
			}
			if(entity.getEndTime()!=null && !entity.getEndTime().equals("")){
				whereHQL.append("o.happenTime <=? ").append(BaseQuery.AND);
				param.add(entity.getEndTime());
			}
	
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return StatmentOrderDetailViewDao.findDao(hql, whereHQL.toString(), param, orderby);
	}

}
